<table cellpadding="0" cellspacing="0" id='tables'>
<tr>
<th>STT</th>
<th>Mã môn</th>
<th>Tên môn</th>
<th>Số TC</th>
<th>A</th>
<th>B+</th>
<th>B</th>
<th>C+</th>
<th>C</th>
<th>D+</th>
<th>D</th>
<th>F</th>
</tr>
<?php $stt = 1;?>
<?php foreach ($kq as $val):?>
<tr>
<th><?php echo $stt?></th>
<th><?php echo $val['mon']['mamom']?></th>
<th><?php echo $val['mon']['tenMon']?></th>
<th><?php echo $val['mon']['soTc']?></th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='A')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='B+')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='B')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='C+')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='C')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='D+')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='D')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
<th><?php foreach ($ketqua as $valkq)
{
	if($valkq['mon']['id'] == $val['mon']['id'] && $valkq['bd']['diemchu']=='F')
		echo $valkq[0]['sodiemchu']*100/ $val[0]['sosv'].'%';
}?>
</th>
</tr>
<?php $stt++;?>
<?php endforeach;?>
</table>
<?php ?>